package com.lz.ionicbase.engine.callback;

import android.content.Context;

import com.lz.ionicbase.widget.Notice;

import okhttp3.Call;
import okhttp3.Response;

/**
 * Created by wyfei on 2017/3/27.
 */

public abstract class AppCallback<T> extends BaseCallback<T> {

    private Context context;

    public AppCallback(Context context) {
        this.context = context;
    }

    @Override
    public void onError(Call call, Response response, Exception e) {
        super.onError(call, response, e);

        if (e.getClass().getSimpleName().equals("ConnectException")) {
            //无网络
            Notice.noNetWork(context, null);
        } else if (e.getClass().getSimpleName().equals("SocketTimeoutException")) {
            //连接超时
            Notice.alertSetServer(context);
        } else {
            Notice.dataException(context);
        }
    }

}
